clear
R=120;
C=33e-12;
TAY=R*C;
T=TAY/100;
t=0:T:(32*TAY);
N=length(t);
U(1)=0;
U1(1)=0;
omega=1e9;
E(1)=sin(T*omega);
sdtn=3;
E3(1)=0.5*sin(T*omega);
U3(1)=0;

E4(1)=2*sin(T*omega);
U4(1)=0;

E5(1)=3*sin(T*omega);
U5(1)=0;


    for k=2:N
        E(k)=sin(k*T*omega);
        E3(k)=0.5*sin(k*T*omega);
        E4(k)=2*sin(k*T*omega);
        E5(k)=3*sin(k*T*omega);
        
        E1(k)=randn(1,1)*sdtn;
        if E(k)>U(k-1) 
            U(k)=U(k-1)-(T/TAY)*U(k-1)+E(k)*T/TAY;
           
         else
            U(k)=U(k-1);
        end
        
        
        if E3(k)>U3(k-1) 
            U3(k)=U3(k-1)-(T/TAY)*U3(k-1)+E3(k)*T/TAY;
           
         else
            U3(k)=U3(k-1);
        end
        
        
        
        if E4(k)>U4(k-1) 
            U4(k)=U4(k-1)-(T/TAY)*U4(k-1)+E4(k)*T/TAY;
           
         else
            U4(k)=U4(k-1);
        end
        if E5(k)>U5(k-1) 
            U5(k)=U5(k-1)-(T/TAY)*U5(k-1)+E5(k)*T/TAY;
           
         else
            U5(k)=U5(k-1);
        end
        
        if E1(k)>U1(k-1) 
            U1(k)=U1(k-1)-(T/TAY)*U1(k-1)+E1(k)*T/TAY;
           
    	else
            U1(k)=U1(k-1);
        end
    
    
end;

%plot(t,U3,t,U4,t,U5,t,U,'green');
legend('0.5','2','3','1')
plot(t,E1)